package com.jrh.dal.user.like;

import java.util.List;
import java.util.Map;

import com.jrh.dal.BaseDao;
import com.jrh.domain.common.Page;
import com.jrh.domain.entity.Product;

/**
 * 用户喜欢商品DAO
 * 
 * @author jasen.hsu.cn@gmail.com 2012-8-7 下午8:03:03
 */
public class UserLikeProductDao extends BaseDao<Product> implements UserLikeReadDao<Product> {

    public UserLikeProductDao(){
        namespace = "jrh.single.product";
    }

    @Override
    public Page<Product> listUserLikeItems(Long userId, Integer start, Integer pageSize, Long style, Long category) {
        Map<String, Object> map = this.getPageMap(start, pageSize);
        map.put("style", style);
        map.put("category", category);
        map.put("userId", userId);
        @SuppressWarnings("unchecked")
        List<Product> productList = (List<Product>) sqlMapClientTemplate.queryForList(namespace + ".listUserlike", map);
        Integer count = (Integer) sqlMapClientTemplate.queryForObject(namespace + ".listUserlike_count", map);
        return new Page<Product>(productList, start, pageSize, count);
    }

}
